/**   
 * @Title: BaseAuthService.java 
 * @Package avicit.cbb.businessclass.system.dataauth.bs 
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author A18ccms A18ccms_gmail_com   
 * @date 2014-10-17 下午1:59:40 
 * @version V1.0   
 */
package avicit.cbb.businessclass.system.dataauth.service.impl;

import java.sql.Clob;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import avicit.platform6.core.context.ThreadContextHelper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import avicit.cbb.businessclass.system.dataauth.domain.CbbAuthResource;
import avicit.cbb.businessclass.system.dataauth.service.BaseExtendAuthService;
import avicit.platform6.commons.utils.ComUtil;
import avicit.platform6.commons.utils.PojoUtil;
import avicit.platform6.core.domain.BeanBase;
import avicit.platform6.core.exception.DaoException;
import avicit.platform6.core.jdbc.JdbcAvicit;
import avicit.platform6.core.properties.PlatformConstant.OpResult;
import avicit.platform6.core.properties.PlatformConstant.OpType;
import avicit.platform6.core.service.ServiceBase;
import avicit.platform6.api.session.SessionHelper;
import avicit.platform6.modules.system.syslog.service.LogBaseFactory;
import avicit.platform6.modules.system.syslog.service.SysLogUtil;

/**
 * <p>
 * 金航数码科技有限责任公司
 * </p>
 * <p>
 * 作者：ruyc
 * </p>
 * <p>
 * 邮箱：ruyc@avicit.com
 * </p>
 * <p>
 * 创建时间： 2014-10-17 下午1:59:40
 * </p>
 * <p>
 * 类说明：数据权限的基础服务类，所有注册的权限服务继承该类，并重写该类相应的方法进行拓展
 * </p>
 * <p>
 * 修改记录：张坚 2014-11-25：用于LANTOP系统资源权限管理模块使用
 * </p>
 */
@Service(value = "BaseAuthService")
@SuppressWarnings("unchecked")
public class BaseAuthService extends ServiceBase implements BaseExtendAuthService {

	// 基本操作类型【访问】
	public static final String OPERATE_VIEW_KEY = "view";
	public static final String OPERATE_VIEW_VALUE = "访问权限";
	// 基本操作类型【编辑】
	public static final String OPERATE_EDIT_KEY = "edit";
	public static final String OPERATE_EDIT_VALUE = "编辑权限";
	// 基本操作类型【删除】
	public static final String OPERATE_DELETE_KEY = "delete";
	public static final String OPERATE_DELETE_VALUE = "删除权限";

	// 基本操作类型【浏览】 add by xiongyy
	public static final String OPERATE_READ_KEY = "read";
	public static final String OPERATE_READ_VALUE = "浏览权限";

	// 基本操作类型【打印】add by xiongyy
	public static final String OPERATE_PRINT_KEY = "print";
	public static final String OPERATE_PRINT_VALUE = "打印权限";

	// 基本操作类型【下载】add by xiongyy
	public static final String OPERATE_DOWNLOAD_KEY = "download";
	public static final String OPERATE_DOWNLOAD_VALUE = "下载";

	// 权限资源表名称，如果定制权限资源表，此处提供定制的表名
	public String authTable = BaseExtendAuthService.DEFAULT_AUTH_TABLE;;

	@Resource
	JdbcTemplate jdbcTemplate;
	@Resource
	JdbcAvicit jdbcAvicit;

	@Override
	public String getServiceId() {
		// TODO 提供权限服务ID
		return "server_id";
	}

	@Override
	public String getServiceTitle() {
		// TODO 提供权限服务展示名称
		return "server_name";
	}

	@Override
	public LinkedHashMap<String, Map<String, Object>> getAuthType(int level) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getResourceTableName() {
		// TODO 获得注册表名
		return authTable;
	}

	@Override
	public Map<String, String> getOperateInfo() {
		Map<String, String> operateMap = new HashMap<String, String>();
		operateMap.put(OPERATE_VIEW_KEY, OPERATE_VIEW_VALUE);
		operateMap.put(OPERATE_EDIT_KEY, OPERATE_EDIT_VALUE);
		operateMap.put(OPERATE_DELETE_KEY, OPERATE_DELETE_VALUE);
		return operateMap;
	}

	//

	// 通过代码注册数据权限配置所需的业务属性
	@Override
	public Map<String, Map<String, Map<String, String>>> getAttributeInfo() {
		Map<String, Map<String, Map<String, String>>> mapAll = new HashMap<String, Map<String, Map<String, String>>>();
		// 分组
		Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
		Map<String, String> m = new HashMap<String, String>();
		m.put("key", "1,2");
		m.put("val", "元素属性,目标数据属性");
		map.put("a", m);
		m = new HashMap<String, String>();
		m.put("key", "=,>,<,<=");
		m.put("val", "等于,大于,小于,小于等于");// //此处需要写成汉字不能使用（=,>,<,<=）包含特殊符号
		map.put("b", m);
		m = new HashMap<String, String>();
		m.put("key", "1,2");
		m.put("val", "," + SessionHelper.getLoginName() + "");
		map.put("c", m);
		mapAll.put("group", map);
		// 条件
		map = new HashMap<String, Map<String, String>>();
		m = new HashMap<String, String>();
		m.put("key", "1,2");
		m.put("val", "并且,或者");
		map.put("a", m);
		m = new HashMap<String, String>();
		m.put("key", "=,>,<,<=");
		m.put("val", "等于,大于,小于,小于等于");// 此处需要写成汉字不能使用（=,>,<,<=）包含特殊符号
		map.put("b", m);
		m = new HashMap<String, String>();
		m.put("key", "1,2");
		m.put("val", "," + SessionHelper.getLoginName() + "");
		map.put("c", m);
		mapAll.put("input", map);
		return mapAll;
	}

	@Override
	public Map<String, Boolean> getAuthOperate(String resourceId) {
		// TODO 根据getResourceTableName()获取的表名和传入的资源ID查询出操作权限
		return null;
	}

	@Override
	public String getAuthData(String resourceId) {
		// TODO 根据getResourceTableName()获取的表名和传入的资源ID查询出数据权限

		return null;
	}

	@Override
	public String getAuthDataConfig(String resourceId, String sysId) {
		// TODO 根据getResourceTableName()获取的表名和传入的资源ID查询出数据权限页面配置
		// String tableName=this.getResourceTableName();//获取表名
		/*
		 * StringBuffer sql=new StringBuffer(); sql.append("SELECT CODE FROM CBB_AUTH_RESOURCE "); if(null!=resourceId&&""!=resourceId){ sql.append("  WHERE ID = '");
		 * sql.append(resourceId); sql.append("'"); } if(null!=sysId&&""!=sysId){ sql.append("  AND SYS_ID = '"); sql.append(sysId); sql.append("'"); }
		 */
		String sqls = "SELECT DATA_AUTH_CONFIG FROM CBB_AUTH_RESOURCE WHERE ID='" + resourceId + "' AND SYS_ID='" + sysId + "'";
		// Map<String, String> map = new HashMap<String, String>();
		// map.put("tableName", tableName);
		// map.put("resourceId", resourceId);
		// List<Object> xmllist=this.jdbcAvicit.query(sqls, map, new
		// BeanPropertyRowMapper<Object>(Object.class));
		List<Object> xmllist = this.hibernateDao.findBySQL(sqls);
		Clob clob = null;
		String xmlData = "";
		if (xmllist != null && xmllist.size() > 0) {
			Object obj = xmllist.get(0);
			if (obj != null) {
				clob = (Clob) obj;
			}
		}

		try {
			if (clob != null && clob.length() > 0) {
				xmlData = clob.getSubString(1, (int) clob.length());
			}
		} catch (SQLException e) {
			e.printStackTrace();
			xmlData = null;
		}
		return xmlData;
	}

	public void setAuthTable(String authTable) {
		this.authTable = authTable;
	}

	private Set<String> codes;

	/**
	 * 资源修改的保存
	 */
	@Override
	public void saveCbb(CbbAuthResource[] inserts, String sysId) throws DaoException {
		Set<CbbAuthResource> add = new HashSet<CbbAuthResource>();
		Set<CbbAuthResource> upd = new HashSet<CbbAuthResource>();
		codes = new HashSet<String>();
		for (CbbAuthResource cbb : inserts) {
			if (verifyCode(cbb) || isExitCbbCode(cbb)) {
				throw new DaoException("code重复");
			}
			if (cbb.getId().equals("-1")) {
				insertAuthCbb(cbb);// 执行增加的方法
			} else {
				upd.add(cbb);
			}
		}
		for (CbbAuthResource cbb : add) {
			insertAuthCbb(cbb);
		}
		for (CbbAuthResource cbb : upd) {
			updateCbbResourse((BeanBase) cbb, sysId);// 执行修改的方法
		}
	}

	/**
	 * 验证提交code是否重复
	 * 
	 * @param cbb
	 * @return
	 */
	public boolean verifyCode(CbbAuthResource cbb) {
		if (codes.size() > 0) { // 添加数据中是否有重复的预算编号
			Iterator<String> ite = codes.iterator();
			while (ite.hasNext()) {
				if (ite.next().equals(cbb.getCode())) {
					return true;
				}
			}
			codes.add(cbb.getCode());
		}
		return false;
	}
	/**
	 * 根据系统id更新资源信息
	 * @param bean
	 * @param sysId
	 * @throws DaoException void
	 * @throws
	 */
	public void updateCbbResourse(BeanBase bean, String sysId) throws DaoException {
		CbbAuthResource cbbAuthResource = (CbbAuthResource) bean;// 新对象
		if (cbbAuthResource == null) {
			throw new DaoException(bean.toString() + "对象转换为cbbAuthResource对象出错！");
		}
		CbbAuthResource cbbAuthResources = hibernateDao.get(CbbAuthResource.class, cbbAuthResource.getId());// 旧的对象
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT CODE FROM CBB_AUTH_RESOURCE ");
		sql.append("  WHERE CODE = '");
		sql.append(cbbAuthResources.getCode());
		sql.append("'");
		if (null != sysId && !"".equals(sysId)) {
			sql.append(" AND SYS_ID='");
			sql.append(sysId);
			sql.append("'");
		}
		List<Object> objList = hibernateDao.findBySQL(sql.toString());
		if (objList != null && objList.size() > 0) {
			// String code = (String) objList.get(0);
			StringBuffer sqls = new StringBuffer();
			sqls.append("UPDATE CBB_AUTH_RESOURCE");
			if (null != cbbAuthResource.getCode() && !"".equals(cbbAuthResource.getCode())) {
				sqls.append(" SET CODE = '");
				sqls.append(cbbAuthResource.getCode());
				sqls.append("'");
			}
			if (null != cbbAuthResource.getName() && !"".equals(cbbAuthResource.getName())) {
				sqls.append("  ,NAME = '");
				sqls.append(cbbAuthResource.getName());
				sqls.append("'");
			}

			if (null != cbbAuthResources.getCode() && !"".equals(cbbAuthResources.getCode())) {
				sqls.append(" WHERE CODE = '");
				sqls.append(cbbAuthResources.getCode());
				sqls.append("'");
			}
			this.jdbcAvicit.getJdbcTemplate().execute(sqls.toString());
			SysLogUtil.log("数据权限模块", "修改资源信息", OpType.update, OpResult.success, LogBaseFactory.getLogBase());
		}

	}

	/**
	 * 注册资源保存的方法
	 */
	@Override
	public void insertAuthCbb(CbbAuthResource cbbAuthResource) throws DaoException {

		cbbAuthResource.setId(ComUtil.getId());
		cbbAuthResource.setDeptId(ThreadContextHelper.getDeptId());// 部门id自己先写的测试数据
		cbbAuthResource.setOrgId(ThreadContextHelper.getOrgId());// 组织id
		cbbAuthResource.setSysId("CBB");
		// 将设置六个必填字段；
		PojoUtil.setSysProperties(cbbAuthResource, OpType.insert);
		hibernateDao.save(cbbAuthResource);
		SysLogUtil.log(cbbAuthResource, null, OpType.insert, OpResult.success);

	}

	/**
	 * 批量删除,删除与当前code相同的数据
	 * @param ids
	 *            资源id
	 */
	public void deleteCbbResourseById(String[] ids, String sysId) {
		for (String id : ids) {
			CbbAuthResource cbbAuthResource = hibernateDao.get(CbbAuthResource.class, id);
			StringBuffer sql = new StringBuffer();
			sql.append("SELECT CODE FROM CBB_AUTH_RESOURCE ");
			sql.append("  WHERE CODE = '");
			sql.append(cbbAuthResource.getCode());
			sql.append("'");
			if (null != sysId && !"".equals(sysId)) {
				sql.append(" AND SYS_ID='");
				sql.append(sysId);
				sql.append("'");
			}
			List<Object> objList = hibernateDao.findBySQL(sql.toString());
			if (objList != null && objList.size() > 0) {
				String code = (String) objList.get(0);
				StringBuffer sqls = new StringBuffer();
				sqls.append("DELETE FROM CBB_AUTH_RESOURCE");
				sqls.append(" WHERE CODE = '");
				sqls.append(code);
				sqls.append("'");
				this.jdbcAvicit.getJdbcTemplate().execute(sqls.toString());
				SysLogUtil.log("数据权限模块", "删除资源删除信息", OpType.delete, OpResult.success, LogBaseFactory.getLogBase());
			}

		}

	}

	@Override
	public void insertAuthData(String resourseId, String htmlScript, String sql, String serverId) {
		try {

			CbbAuthResource objold = hibernateDao.get(CbbAuthResource.class, resourseId);
			hibernateDao.evict(objold);
			CbbAuthResource objnew = objold;
			objnew.setDataAuthConfig(htmlScript);
			objnew.setDataAuth(sql);
			PojoUtil.setSysProperties(objnew, OpType.update);
			hibernateDao.update(objnew);
			SysLogUtil.log(objnew, null, OpType.insert, OpResult.success);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * 修改操作类型和操作权限的状态
	 */
	public void updateType(Map<String, String[]> map, String targetId, String type) {
		// TODO 修改操作类型和操作权限的状态

		String[] ids = map.get("ids");
		String[] types = map.get("types");
		String[] vals = map.get("vals");
		for (int i = 0; i < ids.length; i++) {
			CbbAuthResource c = hibernateDao.get(CbbAuthResource.class, ids[i]);
			hibernateDao.evict(c);
			CbbAuthResource old = c;
			if (null != c.getTargetId() && !"".equals(c.getTargetId())) {
				c.setActionType(types[i]);
				c.setOperateAuth(vals[i]);
				this.hibernateDao.update(c);
				SysLogUtil.log(c, old, OpType.update, OpResult.success);
			} else {
				CbbAuthResource cbb = new CbbAuthResource();
				cbb.setId(ComUtil.getId());
				cbb.setOrgId(ThreadContextHelper.getOrgId());
				cbb.setDeptId(ThreadContextHelper.getDeptId());
				cbb.setSysId("CBB");
				cbb.setTargetType(type);
				cbb.setAuthServiceId(c.getAuthServiceId());
				cbb.setName(c.getName());
				cbb.setCode(c.getCode());
				cbb.setTargetId(targetId);
				cbb.setActionType(types[i]);
				cbb.setOperateAuth(vals[i]);
				PojoUtil.setSysProperties(cbb, OpType.insert);
				this.hibernateDao.save(cbb);
				SysLogUtil.log(cbb, null, OpType.insert, OpResult.success);
			}
		}

	}

	/**
	 * 判断唯一性的共同的方法false代表可以添加，true代表不可以添加；
	 */
	public boolean isExitCbbCode(CbbAuthResource e) {

		StringBuffer sql = new StringBuffer("SELECT count(1) FROM CBB_AUTH_RESOURCE T ");
		sql.append("  WHERE T.CODE = '");
		sql.append(e.getCode());
		sql.append("'");
		if (!e.getId().equals("-1")) {
			sql.append("  AND T.CODE != (SELECT CODE FROM CBB_AUTH_RESOURCE WHERE ID='");
			sql.append(e.getId());
			sql.append("')");

		}
		boolean bool = false;
		List<Object> objList = hibernateDao.findBySQL(sql.toString());
		if (objList != null && objList.size() > 0) {
			int count = Integer.valueOf(String.valueOf(objList.get(0)));
			bool = count == 0 ? false : true;
		}
		return bool;

	}

	@Override
	public void delete(BeanBase arg0) throws DaoException {
		// TODO Auto-generated method stub

	}

	@Override
	public void insert(BeanBase arg0) throws DaoException {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(BeanBase bean) throws DaoException {

	}

	/* 张坚修改内容 2014-11-25：begin */

	@Override
	public void deleteCbbAuthResource(String orgId, String sysId, String targetId, String serviceId, String menuId) throws Exception {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("DELETE FROM CBB_AUTH_RESOURCE T ");
		sbSql.append(" WHERE T.ORG_ID = '");
		sbSql.append(orgId);
		sbSql.append("'   AND T.SYS_ID = '");
		sbSql.append(sysId);
		sbSql.append("'   AND T.TARGET_ID = '");
		sbSql.append(targetId);
		sbSql.append("'   AND T.AUTH_SERVICE_ID = '");
		sbSql.append(serviceId);
		sbSql.append("' ");
		if (serviceId.equals("LANTOP_AUTH_SERVER_FUNC")) { // 档案功能操作权限时有此条件
			sbSql.append("    AND T.CODE = '");
			sbSql.append(menuId);
			sbSql.append("'");
		}
		this.jdbcAvicit.getJdbcTemplate().execute(sbSql.toString());
		SysLogUtil.log("数据权限模块", "删除权限资源记录", OpType.delete, OpResult.success, LogBaseFactory.getLogBase());
	}

	@Override
	public void insertCbbAuthResource(CbbAuthResource cbbAuthResource) throws Exception {
		cbbAuthResource.setId(ComUtil.getId());
		PojoUtil.setSysProperties(cbbAuthResource, OpType.insert);
		hibernateDao.save(cbbAuthResource);
		SysLogUtil.log(cbbAuthResource, null, OpType.insert, OpResult.success);
	}

	@Override
	public String getResourceOperateAuth(String orgId, String sysId, String targetId, String serviceId, String code, String actionType) {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT T.OPERATE_AUTH FROM CBB_AUTH_RESOURCE T ");
		sbSql.append(" WHERE T.ORG_ID = '");
		sbSql.append(orgId);
		sbSql.append("'   AND T.SYS_ID = '");
		sbSql.append(sysId);
		sbSql.append("'   AND T.TARGET_ID = '");
		sbSql.append(targetId);
		sbSql.append("'   AND T.AUTH_SERVICE_ID = '");
		sbSql.append(serviceId);
		sbSql.append("'   AND T.CODE = '");
		sbSql.append(code);
		sbSql.append("'   AND T.ACTION_TYPE = '");
		sbSql.append(actionType);
		sbSql.append("'");
		List<Map<String, Object>> list = this.jdbcAvicit.queryForMap(sbSql.toString(), null);
		String operateAuth = "";
		if (null != list && list.size() > 0) {
			operateAuth = (String) list.get(0).get("OPERATE_AUTH");
		}
		return operateAuth;
	}

	@Override
	public void deleteCbbAuthResource(String orgId, String sysId, String targetType, String targetId, String authServiceId, String code, String actionType) throws Exception {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("DELETE FROM CBB_AUTH_RESOURCE T ");
		sbSql.append(" WHERE T.ORG_ID = '");
		sbSql.append(orgId);
		sbSql.append("'   AND T.SYS_ID = '");
		sbSql.append(sysId);
		sbSql.append("'   AND T.TARGET_TYPE = '");
		sbSql.append(targetType);
		sbSql.append("'   AND T.TARGET_ID = '");
		sbSql.append(targetId);
		sbSql.append("'   AND T.AUTH_SERVICE_ID = '");
		sbSql.append(authServiceId);
		sbSql.append("'   AND T.CODE = '");
		sbSql.append(code);
		sbSql.append("'   AND T.ACTION_TYPE = '");
		sbSql.append(actionType);
		sbSql.append("'");
		this.jdbcAvicit.getJdbcTemplate().execute(sbSql.toString());
		SysLogUtil.log("数据权限模块", "删除权限资源记录", OpType.delete, OpResult.success, LogBaseFactory.getLogBase());
	}

	@Override
	public CbbAuthResource getCbbAuthResource(String orgId, String sysId, String targetType, String targetId, String authServiceId, String code, String actionType) {
		String hql = " from CbbAuthResource where orgId = ? and sysId = ? and targetType = ? and targetId = ? and authServiceId = ? and code = ? and actionType = ?";
		List<CbbAuthResource> list = this.hibernateDao.find(hql, new Object[] {orgId, sysId, targetType, targetId, authServiceId, code, actionType});
		if (null != list && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

	@Override
	public void updateCbbAuthResource(CbbAuthResource cbbAuthResource) throws Exception {
		CbbAuthResource objOld = this.hibernateDao.get(CbbAuthResource.class, cbbAuthResource.getId());
		hibernateDao.evict(objOld);
		CbbAuthResource temp = objOld;
		try {
			PojoUtil.copyProperties(temp, cbbAuthResource, true);
		} catch (Exception e) {
			e.printStackTrace();
		}
		PojoUtil.setSysProperties(temp, OpType.update);
		hibernateDao.update(temp);
		SysLogUtil.log(cbbAuthResource, objOld, OpType.update, OpResult.success);
	}

	@Override
	public void delCbbAuthResourceById(String ids) throws Exception {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("DELETE FROM CBB_AUTH_RESOURCE T WHERE T.ID IN (");
		sbSql.append(ids);
		sbSql.append(")");
		this.jdbcAvicit.getJdbcTemplate().execute(sbSql.toString());
		SysLogUtil.log("数据权限模块", "删除权限资源记录", OpType.delete, OpResult.success, LogBaseFactory.getLogBase());
	}

	@Override
	public boolean isInitUser(String orgId, String sysId, String targetType, String targetId, String authServiceId) {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT ID ");
		sbSql.append("  FROM CBB_AUTH_RESOURCE T ");
		sbSql.append(" WHERE T.ORG_ID = '");
		sbSql.append(orgId);
		sbSql.append("'   AND T.SYS_ID = '");
		sbSql.append(sysId);
		sbSql.append("'   AND T.TARGET_TYPE = '");
		sbSql.append(targetType);
		sbSql.append("'   AND T.TARGET_ID = '");
		sbSql.append(targetId);
		sbSql.append("'   AND T.AUTH_SERVICE_ID = '");
		sbSql.append(authServiceId);
		sbSql.append("'");
		List<Map<String, Object>> list = this.jdbcAvicit.queryForMap(sbSql.toString(), null);
		if (null != list && list.size() > 0) {
			return true;
		}
		return false;
	}

	@Override
	public void delCbbAuthResource(String orgId, String deptId, String sysId, String targetType, String targetId, String code) throws Exception {
		// 删除操作权限、条件设置
		StringBuffer sbSql1 = new StringBuffer();
		sbSql1.append("DELETE FROM CBB_AUTH_RESOURCE WHERE ORG_ID = '" + orgId + "' AND DEPT_ID = '" + deptId + "' AND SYS_ID = '" + sysId + "' AND TARGET_TYPE = '" + targetType
				+ "' AND TARGET_ID = '" + targetId + "' AND CODE LIKE '" + code + "%'");
		this.jdbcAvicit.getJdbcTemplate().execute(sbSql1.toString());
	}

	@Override
	public void delCbbAuthResource(String orgId, String deptId, String sysId, String targetId) throws Exception {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("DELETE FROM CBB_AUTH_RESOURCE WHERE TARGET_ID = '" + targetId + "'");
		this.jdbcAvicit.getJdbcTemplate().execute(sbSql.toString());
	}

	@Override
	public List<CbbAuthResource> getCbbAuthResource(String orgId, String deptId, String sysId, String targetId) {
		List<CbbAuthResource> list = this.hibernateDao.find(" from CbbAuthResource where orgId = ? and sysId = ? and targetId = ?", new Object[] {orgId, 
				sysId, targetId});
		return list;
	}

	/* 张坚修改内容 2014-11-25：end */

}
